﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlickrNet;
using System.Xml.Serialization;
using MediaArtAggregator.Core.Configuration;

namespace MediaArtAggregator.Core.SearchProvider {
  [XmlRoot("source")]
  public class FlickrSearchSource : ApiBasedSearchSource {

    public override void Search ( string search, Settings settings, SearchType searchType ) {
      this.OnSearchInitialize ( EventArgs.Empty );
      Flickr flickr = new Flickr ("d8ae7dd999730fbcec857da63a94111c" ,"4fc5db3b8043db55");
      Photos photos = flickr.PhotosSearch ( search, TagMode.AnyTag,string.Empty );
      foreach ( Photo photo in photos.PhotoCollection ) {
        this.Results.Add ( new Uri ( photo.LargeUrl ) );
      }
      this.OnSearchComplete ( EventArgs.Empty );
    }

    public override string ToString ( ) {
      return "www.flickr.com";
    }
  }
}
